package co.fitstart.entity.courseware;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

@Entity
@Table(name = "courseware_tag")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class CoursewareTag {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 健身标签名称 */
    private String name;
    
    /** 健身标签描述信息 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String description;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private FitnessTag FitnessTag;
    
    @Column(name = "is_disabled")
    @JSONField(serialize = false)
    private boolean disabled;
    
    public CoursewareTag() {
        
    }
    
    /**
     * 
     * @param fitnessTag
     */
    public CoursewareTag(FitnessTag fitnessTag) {
        this.name = fitnessTag.getName();
        this.description = fitnessTag.getDescription();
        this.FitnessTag = fitnessTag;
        this.disabled = false;
    }
    
    /**
     * 
     * @param name
     * @param description
     * @return
     */
    public CoursewareTag edit(String name, String description) {
        this.name = name;
        this.description = description;
        return this;
    }

    /**
     * 
     * @return
     */
    public String getCover() {
        return FitnessTag.getCover();
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @return the fitnessTag
     */
    public FitnessTag getFitnessTag() {
        return FitnessTag;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @param fitnessTag the fitnessTag to set
     */
    public void setFitnessTag(FitnessTag fitnessTag) {
        FitnessTag = fitnessTag;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
